<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");

$url = $_GET['url'];
if (!empty($url)) {
    $context = stream_context_create(array('http' => array('timeout' => 5)));
    $html = @file_get_contents($url, false, $context);
    if ($html !== false) {
        echo trim($html);
        // echo '<script>console.log(' . $html . ')</script>';
    } else {
        echo "Error: unable to fetch HTML content from the URL.";
    }
} else {
    echo "Error: missing URL parameter.";
}
